﻿using Futuret.Repositor.Db;

namespace Futuret.Repositor.Reositors;

/// <summary>
///  Author: Riva
///  Date: 2023/7/11 17:39 
///  Description: 仓储实现
/// </summary>
public class DbRepository<T>: SimpleClient<T>, IDbRepository<T> where T : class, new()
{
    /// <summary>
    /// 
    /// </summary>
    /// <param name="context"></param>
    public DbRepository(ISqlSugarClient? context = null) : base(context) //注意这里要有默认值等于null
    {
        base.Context = DbContext.Db.GetConnectionScopeWithAttr<T>(); //ioc注入的对象
        itenant = DbContext.Db;
    }
    
    /// <summary>
    /// 多租户事务、GetConnection、IsAnyConnection等功能
    /// </summary>
    public ITenant itenant { get; set; }

    /// <summary>
    /// 上下文
    /// </summary>
    public ISqlSugarClient? context => base.Context;
}